using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;

namespace Toodledo.Security
{
    public class ToodledoPrincipal : IPrincipal
    {
        private ToodledoIdentity _identity;
        private string[] _roles;

        public ToodledoPrincipal(ToodledoIdentity identity)
        {
            _identity = identity;
        }

        public ToodledoPrincipal(ToodledoIdentity identity, string[] roles)
        {
            _identity = identity;
            _roles = roles;
        }
        
        #region IPrincipal Members

        public IIdentity Identity
        {
            get
            {
                return _identity;
            }
        }

        public bool IsInRole(string role)
        {
            return _roles.Contains(role, StringComparer.InvariantCultureIgnoreCase);
        }
        #endregion
    }
}
